package com.xbongbong.paas.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;

/**
 * @author: wufeng
 * @date: 2018/10/24 16:59
 * @desrcption: 默认值
 */
public enum DefaultTypeEnum {

    /**
     * 选项的三种类型
     */
    CUSTOM(0, "custom", "enum.defaultType.memo.custom"),
    LINKFORM(1, "linkForm", "enum.defaultType.memo.linkform"),
    DATARELY(2, "dataRely", "enum.defaultType.memo.datarely"),
    LINK_ADD(3, "linkAdd", "enum.defaultType.memo.link_add"),
    TODAY(4, "today", "enum.defaultType.memo.today"),
    FORMULA(5, "formula", "enum.defaultType.memo.formula"),
    DYNAMIC(6, "dynamic", "enum.defaultType.memo.dynamic"),
    LINK_DATA(7, "linkData", "enum.defaultType.memo.link_data"),
    LINK_DATA_MULTI(11, "linkDataMulti", "enum.defaultType.memo.link_data_multi"),

    PRODUCT_DATA_RELY(8, "productDataRely", "enum.defaultType.memo.product_data_rely"),

    /**
     * 日期由后端计算好返回，付款单，回款单
     */
    DATE_BY_BACK_END(9, "dateByBackEnd", "enum.defaultType.memo.date_by_back_end"),

    BUSINESS_FIELD(10,"business","enum.defaultType.memo.business_field"),
    ;

    private Integer type;

    private String alias;

    private String memo;

    DefaultTypeEnum(Integer type, String alias, String memo){
        this.type =type;
        this.alias = alias;
        this.memo = memo;
    }

    public Integer getType() {
        return type;
    }

    public String getAlias() {
        return alias;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }

    public static DefaultTypeEnum getComboTypeEnum(Integer type){
        for (DefaultTypeEnum combo: values()){
            if(combo.getType().equals(type)){
                return combo;
            }
        }
        return null;
    }
}
